/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.pucp.dp1.TSPSolution.view;

import javax.swing.JPanel;
import pe.edu.pucp.dp1.TSPSolution.view.componentes.Index;

/**
 *
 * @author walter
 */
public class Frm_ConsultarServicio extends javax.swing.JPanel {

    /**
     * Creates new form Frm_ConsultarServicio
     */
    public Frm_ConsultarServicio() {
        initComponents();
        tblBuscarServicio.setVisible( false ) ;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        lblNombreServicio = new javax.swing.JLabel();
        txtNombreServicio = new javax.swing.JTextField();
        cbxEstadoServicio = new javax.swing.JComboBox();
        lblEstadoServicio = new javax.swing.JLabel();
        btnBuscarServicio = new javax.swing.JButton();
        btnCancelarBuscarServicio = new javax.swing.JButton();
        btnLimpiarBuscarServicio = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        tblBuscarServicio = new javax.swing.JTable();
        btnRegistrarServicio = new javax.swing.JButton();
        btnModificarServicio = new javax.swing.JButton();

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Consultar Servicio"));

        lblNombreServicio.setText("Nombre");

        cbxEstadoServicio.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Activo", "Inactivo" }));

        lblEstadoServicio.setText("Estado");

        btnBuscarServicio.setText("Buscar");
        btnBuscarServicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnBuscarServicioMouseReleased(evt);
            }
        });

        btnCancelarBuscarServicio.setText("Cancelar");
        btnCancelarBuscarServicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnCancelarBuscarServicioMouseReleased(evt);
            }
        });

        btnLimpiarBuscarServicio.setText("Limpiar");
        btnLimpiarBuscarServicio.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                btnLimpiarBuscarServicioMouseReleased(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNombreServicio)
                            .addComponent(lblEstadoServicio)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(38, 38, 38)
                        .addComponent(btnBuscarServicio)))
                .addGap(35, 35, 35)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(cbxEstadoServicio, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(txtNombreServicio))
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnLimpiarBuscarServicio)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE)
                        .addComponent(btnCancelarBuscarServicio)
                        .addGap(32, 32, 32))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblNombreServicio)
                    .addComponent(txtNombreServicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lblEstadoServicio)
                    .addComponent(cbxEstadoServicio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnBuscarServicio)
                    .addComponent(btnCancelarBuscarServicio)
                    .addComponent(btnLimpiarBuscarServicio))
                .addGap(0, 8, Short.MAX_VALUE))
        );

        tblBuscarServicio.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"1", "Express", "19.5", "Activo"},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Código", "Nombre", "Porc. sobre costo", "Estado"
            }
        ));
        jScrollPane1.setViewportView(tblBuscarServicio);

        btnRegistrarServicio.setText("Nuevo");
        btnRegistrarServicio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRegistrarServicioActionPerformed(evt);
            }
        });

        btnModificarServicio.setText("Modificar");
        btnModificarServicio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarServicioActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 349, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(89, 89, 89)
                        .addComponent(btnRegistrarServicio)
                        .addGap(39, 39, 39)
                        .addComponent(btnModificarServicio)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 124, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnRegistrarServicio)
                    .addComponent(btnModificarServicio))
                .addContainerGap(25, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btnBuscarServicioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnBuscarServicioMouseReleased
        // TODO add your handling code here:
        mostrarBusqueda() ;
    }//GEN-LAST:event_btnBuscarServicioMouseReleased

    private void mostrarBusqueda(){
        tblBuscarServicio.setVisible( true ) ;
    }
    
    private void btnLimpiarBuscarServicioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnLimpiarBuscarServicioMouseReleased
        // TODO add your handling code here:
        limpiar() ;
        tblBuscarServicio.setVisible( false ) ;
    }//GEN-LAST:event_btnLimpiarBuscarServicioMouseReleased

    private void btnCancelarBuscarServicioMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCancelarBuscarServicioMouseReleased
        // TODO add your handling code here:
        cerrar() ;
    }//GEN-LAST:event_btnCancelarBuscarServicioMouseReleased

    private void btnRegistrarServicioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRegistrarServicioActionPerformed
        // TODO add your handling code here:
        Frm_RegistrarServicio frm = new Frm_RegistrarServicio() ;
        cambiarVista( frm ) ;
    }//GEN-LAST:event_btnRegistrarServicioActionPerformed

    private void btnModificarServicioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarServicioActionPerformed
        // TODO add your handling code here:
        Frm_ModificarServicio frm = new Frm_ModificarServicio() ;
        cambiarVista( frm ) ;
    }//GEN-LAST:event_btnModificarServicioActionPerformed

    private void cambiarVista( JPanel panel ){
        ((Index)(this.getTopLevelAncestor())).changeContentPane( panel );
    }
    
    private void limpiar(){
        txtNombreServicio.setText( "" ) ;
        cbxEstadoServicio.setSelectedIndex( 0 ) ;
    }
    
    private void cerrar(){
        this.setVisible( true ) ;
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnBuscarServicio;
    private javax.swing.JButton btnCancelarBuscarServicio;
    private javax.swing.JButton btnLimpiarBuscarServicio;
    private javax.swing.JButton btnModificarServicio;
    private javax.swing.JButton btnRegistrarServicio;
    private javax.swing.JComboBox cbxEstadoServicio;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblEstadoServicio;
    private javax.swing.JLabel lblNombreServicio;
    private javax.swing.JTable tblBuscarServicio;
    private javax.swing.JTextField txtNombreServicio;
    // End of variables declaration//GEN-END:variables
}
